<?php
declare (strict_types=1);

namespace app\index\controller;

use app\common\model\Carousel;
use app\common\model\News;
use app\common\model\ProductCate;
use think\facade\Cache;
use think\facade\View;

class Index extends Base
{
    public function index()
    {
        View::assign([
            'carousel' => Carousel::getList(['position' => 1]),
            'news' => News::getList(),
            'cate_list' => ProductCate::getList(['pid' => 0])
        ]);

        return View::fetch();
    }

    public function communal()
    {
        $type = $this->request->param('type');
        $title = ['company' => '关于我们', 'register_msg' => '注册协议', 'privacy_msg' => '隐私协议'];
        View::assign([
            'title' => $title[$type],
            'content' => Cache::get('system')[$type]
        ]);

        return View::fetch();
    }
}
